#ifndef __HI_PAGE1_H
#define __HI_PAGE1_H

static void page1_update_info(void)
{
}

static int get_info(char *file, char *buf, char *start, char *end)
{
	buf = "info";
	return 0;
}

static void page1_generate(void)
{
	char buf[512];
	char buf2[512];

	memset(buf, 0, 512);
	memset(buf2, 0, 512);
	const gchar *str = "Info not ready!";
	logo = g_object_new(GTK_TYPE_IMAGE, "file", "1.png", NULL);
	hostname_label = (GtkLabel *) gtk_label_new(str);
	gtk_label_set_markup(GTK_LABEL(hostname_label), 
			"<span font_desc=\"Times New Bold 20\">Hostname</span>");

	hostname_text = (GtkLabel *) gtk_label_new(str);
	get_info("/proc/sys/kernel/hostname", buf, NULL, NULL);
	gtk_label_set_label(GTK_LABEL(hostname_text), buf);

	linuxsystem_label = (GtkLabel *) gtk_label_new(str);
	gtk_label_set_markup(GTK_LABEL(linuxsystem_label), 
			"<span font_desc=\"Times New Bold 20\">Linux System</span>");

	kernelversion_label = (GtkLabel *) gtk_label_new(str);
	get_info("/proc/sys/kernel/osrelease", buf, NULL, NULL);
	sprintf(buf2, "Kernel version is ");
	strcat(buf2, buf);
	gtk_label_set_label(GTK_LABEL(kernelversion_label), buf2);

	hardware_label = (GtkLabel *) gtk_label_new(str);
	gtk_label_set_markup(GTK_LABEL(hardware_label), 
			"<span font_desc=\"Times New Bold 20\">Hardware Brief Information</span>");

	cpuinfo_text = (GtkLabel *) gtk_label_new(str);
	get_info("/proc/cpuinfo", buf, "model name: ", "\n");
	sprintf(buf2, "CPU Model name is ");
	strcat(buf2, buf);
	gtk_label_set_label(GTK_LABEL(cpuinfo_text), buf2);

	meminfo_text = (GtkLabel *) gtk_label_new(str);
	get_info("/proc/meminfo", buf, "MemTotal: ", "\n");
	sprintf(buf2, "Total Memory ");
	strcat(buf2, buf);
	gtk_label_set_label(GTK_LABEL(meminfo_text), buf2);

	hsep1 = (GtkHSeparator *) gtk_object_new(GTK_TYPE_HSEPARATOR, NULL);
	authorinfo_text = (GtkLabel *)gtk_label_new(str);
	gtk_label_set_justify(authorinfo_text, GTK_JUSTIFY_CENTER);
	gtk_label_set_markup(GTK_LABEL(authorinfo_text), "<span font_desc = \"Purisa Bold 23\" foreground = \"#000066\">Author: Harry and Ilana</span>\n<span font_desc = \"URW Chancery L 15\" style = \"italic\" foreground = \"#00AAAA\">Xiyou 2011 10 23\n Compile succeed under Ubuntu 10.04 with kernel 2.6.32.15</span>");
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(logo), 
			0, grid_h / 10,
			0, grid_v,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(hostname_label), 
			grid_h / 10, grid_h,
			grid_v / 100 * 10, grid_v / 100 * 13,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(hostname_text), 
			grid_h / 10, grid_h,
			grid_v / 100 * 13, grid_v / 100 * 14,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(linuxsystem_label), 
			grid_h / 10, grid_h,
			grid_v / 100 * 17, grid_v / 100 * 20,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(kernelversion_label), 
			grid_h / 10, grid_h,
			grid_v / 100 * 20, grid_v / 100 * 21,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(hardware_label), 
			grid_h / 10, grid_h,
			grid_v / 100 * 24, grid_v / 100 * 27,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(cpuinfo_text), 
			grid_h / 10, grid_h,
			grid_v / 100 * 27, grid_v / 100 * 28,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(meminfo_text), 
			grid_h / 10, grid_h,
			grid_v / 100 * 28, grid_v / 100 * 29,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(hsep1), 
			grid_h / 10, grid_h,
			grid_v / 100 * 40, grid_v / 100 * 41,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	gtk_table_attach(GTK_TABLE(page_table[0]), 
			GTK_WIDGET(authorinfo_text), 
			grid_h / 10, grid_h,
			grid_v / 100 * 55, grid_v / 100 * 65,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
			0, 0);
	page1_update_info();
	return ;
}

#endif
